
#include <Liberty3D/Library/TextureImporter.h>
#include <Liberty3D/Engine/Windows/Stream.h>

using namespace Liberty::Engine;
using namespace Liberty::Library;

using namespace System::IO;
using namespace System::Windows::Media::Imaging;

void TextureCachedData::update(std::streambuf* buf) {
    Stream^ imageSource = CreateInputStream(buf);

    BitmapDecoder^ decoder = BitmapDecoder::Create(
        imageSource,
        BitmapCreateOptions::IgnoreImageCache | BitmapCreateOptions::PreservePixelFormat,
        BitmapCacheOption::None);

    BitmapSource^ source = decoder->Frames[0];

    width  = (size_t)source->Width;
    height = (size_t)source->Height;
    format = Unknown;
}
